package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "inventory_", schema = "crm")
public class Inventory {
    private int inventoryId;
    private Integer inventoryNum;
    private Warehouse warehouseByWarehouseId;
    private Product productByProductId;

    @Id
    @Column(name = "inventory_id", nullable = false)
    public int getInventoryId() {
        return inventoryId;
    }

    public void setInventoryId(int inventoryId) {
        this.inventoryId = inventoryId;
    }


    @Basic
    @Column(name = "inventory_num", nullable = true)
    public Integer getInventoryNum() {
        return inventoryNum;
    }

    public void setInventoryNum(Integer inventoryNum) {
        this.inventoryNum = inventoryNum;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Inventory inventory = (Inventory) o;
        return inventoryId == inventory.inventoryId &&
                Objects.equals(inventoryNum, inventory.inventoryNum);
    }

    @Override
    public int hashCode() {
        return Objects.hash(inventoryId, inventoryNum);
    }

    @ManyToOne
    @JoinColumn(name = "warehouse_id", referencedColumnName = "warehouse_id")
    public Warehouse getWarehouseByWarehouseId() {
        return warehouseByWarehouseId;
    }

    public void setWarehouseByWarehouseId(Warehouse warehouseByWarehouseId) {
        this.warehouseByWarehouseId = warehouseByWarehouseId;
    }

    @ManyToOne
    @JoinColumn(name = "product_id", referencedColumnName = "product_id")
    public Product getProductByProductId() {
        return productByProductId;
    }

    public void setProductByProductId(Product productByProductId) {
        this.productByProductId = productByProductId;
    }
}
